﻿using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Windows.Forms;

namespace UdpApplication{
    public class ClientBuilder{
        public static void Build(Control status,string str){
            status.Text = "";
            status.Text += "信息传输中" + Environment.NewLine;
            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
                ProtocolType.Udp);
            IPAddress broadcast = IPAddress.Parse("127.0.0.1");
            byte[] sendbuf = Encoding.ASCII.GetBytes(str);
            IPEndPoint ep = new IPEndPoint(broadcast, 11000);
            s.SendTo(sendbuf, ep);
            status.Text += "信息已发送" + Environment.NewLine;
        }
    }
}